﻿<?php

ignore_user_abort(TRUE);
require_once("./interface.php");
require_once("./utils.php");
require_once("./interface.php");
require_once("./TechnicFunc.php");
require_once("./SoldierFunc.php");
require_once("./HotelFunc.php");
require_once("./OfficeFunc.php");
require_once("./MarketFunc.php");
require_once("./UnionFunc.php");
require_once("./StoreFunc.php");
require_once("./TroopFunc.php");
require_once("./global.php");
require_once("./report.php");

//mysql_connect()函数
$con = mysql_connect("127.0.0.1","root","111111");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("sanguo1", $con);//链接数据库



    $bin_targetcid_d=235235;
	$i=0;
	$bin_soldiers_2=sql_fetch_into_arrays("select * from sys_city_soldier where cid='$bin_targetcid_d'and count>0 order by sid");	
   mysql_query("DELETE from mem_bin_citysoldiers ");
   while($bin_soldiers_2['sid'][$i]!=""){

    $bin_sid_2=$bin_soldiers_2['sid'][$i];
	$bin_count_2=$bin_soldiers_2['count'][$i];
	$bin_soldiersname_2=sql_fetch_one_cell("select name from cfg_soldier where sid='$bin_sid_2' order by sid");
	$bin_soldier_peopleneed=sql_fetch_one_cell("select people_need from cfg_soldier where sid='$bin_sid_2'");
    
    mysql_query("INSERT INTO mem_bin_citysoldiers (`cid`,`sidname`,`count`,`people_need`) 
    VALUES ('$bin_targetcid_d', '$bin_soldiersname_2', '$bin_count_2','$bin_soldier_peopleneed')");

	//echo $bin_sid_2.'----'.$bin_soldiersname_2.'----'.$bin_count_2.'<br>';
    $i=$i+1;
   }


	$k=0;
    $bin_rs_1=sql_fetch_into_arrays("select * from mem_bin_citysoldiers where cid='$bin_targetcid_d' order by id");
	$bin_rs_2=sql_fetch_into_arrays("select * from sys_city_soldier where cid='135135' order by sid");
    $dfsoldier_info="";
	$bin_rs_sump=0;
    while($bin_rs_1['sidname'][$k]!="")
		{
	    $bin_rs_name1=$bin_rs_1['sidname'][$k];
        $bin_rs_count1=$bin_rs_1['count'][$k];
        $bin_rs_count2=$bin_rs_2['count'][$k];
	    $bin_rs_peopleneed=sql_fetch_one_cell("select people_need from mem_bin_citysoldiers where sidname='$bin_rs_name1'");
		
		$bin_rs_dier2=$bin_rs_count1;
	    if ($bin_rs_count2>0)
		  {
			$bin_rs_dier2=$bin_rs_count1-$bin_rs_count2;
		  }

		$dfsoldier_info=$dfsoldier_info.'<tr><td width="80" height="25" align="center" valign="middle" class="TextArmyCount">'.$bin_rs_name1.'</td><td width="110" height="25" align="center" valign="middle" class="TextArmyCount">'.$bin_rs_count1.'</td><td width="90" height="25" align="center" valign="middle" class="TextArmyCount">'.$bin_rs_dier2.'</td></tr>';
		
        $bin_rs_sump=$bin_rs_sump+$bin_rs_dier2*$bin_rs_peopleneed;
		$k=$k+1;
	}

echo '<table>'.$dfsoldier_info.'</table>';

echo '消灭兵力：'.$bin_rs_sump;





 mysql_close($con);

?>